<?php
class Workout extends AppModel {

	var $name = 'Workout';
	var $actsAs = array(
		'Containable', 
		'Ownable'
		);
	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $belongsTo = array(
		'User' => array(
			'className' => 'User',
			'foreignKey' => 'user_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Template' => array(
			'className' => 'Template',
			'foreignKey' => 'template_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
	
	function findBetweenDates($day1, $day2) {
		//$this->contain('Template.title','Template.id'); ability_id
		$this->contain('Template.title','Template.id','Template.power_zone','Template.time_in_power_zone', array('Template'=>array('Type.id','Type.title', 'Ability.id','Ability.title')));
		$params = array(
			'conditions' => array(
				array('Workout.date >=' => $day1),
				array('Workout.date <=' => $day2)),
			'recursive' => 2, 
			'order' => array('Workout.date' => 'asc','Workout.order' => 'asc')
		);
		return $this->find('all', $params);
	}

}
?>